﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Table=FCNS.Data.Table;

namespace PayS
{
    /// <summary>
    /// WindowInvoice.xaml 的交互逻辑
    /// </summary>
    public partial class WindowInvoice : Window
    {
        public WindowInvoice()
        {
            InitializeComponent();

            InitEvent();
        }

        Table.PayS order = null;
        public void Init(Table.PayS obj)
        {
            order = obj;

            textBox1.Focus();
        }

        private void InitEvent()
        {
            buttonCanel.Click += (ss, ee) => { CanelInvoice(); };
            buttonSave.Click += (ss, ee) => { SaveInvoice(); };
        }

        private void SaveInvoice()
        {
            if (order != null)
            {
                order.UseInvoice = true;
                order.Invoice = textBox1.Text;
                order.UpdateInvoice();
            }
            this.Close();
        }

        private void CanelInvoice()
        {
            if (order != null)
            {
                order.UseInvoice = false;
                order.UpdateInvoice();
            }
            this.Close();
        }
    }
}